//
//  WBBadgeView.m
//  MyWeiBo
//
//  Created by wangneihan on 16/1/25.
//  Copyright © 2016年 wangneihan. All rights reserved.
//

#import "WBBadgeView.h"

@implementation WBBadgeView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        self.userInteractionEnabled = NO;
        [self setBackgroundImage:[UIImage imageNamed:@"main_badge"] forState:UIControlStateNormal];
        
    }
    return self;
}

-(void)setBadgeValue:(NSInteger)badgeValue
{
    _badgeValue = badgeValue;
    if (badgeValue > 0) {
        self.hidden = NO;
    }
    else{
        self.hidden = YES;
    }
    self.titleLabel.text = [NSString stringWithFormat:@"%ld",(long)badgeValue];
}

@end
